package com.cms.rxjava

import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.base.BaseDBActivity
import com.android.baselibrary.base.bindAdapter
import com.android.baselibrary.recycler.grid
import com.cms.rxjava.bean.RxBean
import com.cms.rxjava.databinding.ActivityMainRxjavaBinding
import com.cms.rxjava.router.RxRouter
import com.cms.rxjava.view.RxView

@Route(path = ArouterContains.RXJAVA)
class RxJavaMainActivity : BaseDBActivity<ActivityMainRxjavaBinding>(R.layout.activity_main_rxjava) {
   /* override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
     //   setContentView()





        val disposable = Observable.create { emitter ->
            Log.i(TAG, "Observable onCreate:, 当前线程:" + Thread.currentThread().name)
            emitter.onNext("我是Rxjava")
        } //ObservableCreate.subscribeOn
            .subscribeOn(Schedulers.io()) //ObservableSubscribeOn.observeOn
            .observeOn(AndroidSchedulers.mainThread()) //ObservableObserveOn.subscribeActual
            .subscribe { s: String ->
                Log.i(TAG, "onCreate: " + s + ", 当前线程:" + Thread.currentThread().name)
            }


      *//*  val disposable1: Disposable = Observable.defer<String>
        Callable<ObservableSource<String>> { Observable.just<String>("1") }.subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(Consumer<String> { s ->
                Log.i(
                    TAG,
                    "onCreate2: " + s + ", 当前线程:" + Thread.currentThread().name
                )
            })*//*
    }
*/



    companion object {
        private val TAG: String = RxJavaMainActivity::class.java.simpleName
    }

    override fun initView() {
        mBinding.recyclerView.grid(2).bindAdapter<RxBean>(){
            addLayout(RxView(this@RxJavaMainActivity))
        }.setData(mData)
    }

    override fun initVMData() {

    }
    private val mData by lazy {
        mutableListOf(RxBean("interval操作符",RxRouter.RxJava_Interval_fragment))
    }
}